<html>
<head><meta charset="utf-8"><title>impl FromIterator for tuples of items to tuples of collectio · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html">impl FromIterator for tuples of items to tuples of collectio</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210586226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210586226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210586226">(Sep 18 2020 at 23:46)</a>:</h4>
<p>how controversial of a change would it be to add <code>FromIterator</code> impls for combinations of tuples</p>



<a name="210586229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210586229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210586229">(Sep 18 2020 at 23:46)</a>:</h4>
<p>im thinking something like this</p>



<a name="210586233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210586233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210586233">(Sep 18 2020 at 23:46)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="cp">#![feature(extend_one)]</span><span class="w"></span>
<span class="k">use</span><span class="w"> </span><span class="n">std</span>::<span class="n">iter</span>::<span class="p">{</span><span class="n">once</span><span class="p">,</span><span class="w"> </span><span class="n">FromIterator</span><span class="p">};</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">Tuple</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">,</span><span class="w"> </span><span class="n">C</span><span class="o">&gt;</span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">,</span><span class="w"> </span><span class="n">C</span><span class="p">);</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">,</span><span class="w"> </span><span class="n">C</span><span class="p">,</span><span class="w"> </span><span class="n">V</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="o">&gt;</span><span class="w"> </span><span class="n">FromIterator</span><span class="o">&lt;</span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">,</span><span class="w"> </span><span class="n">C</span><span class="p">)</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Tuple</span><span class="o">&lt;</span><span class="n">V</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">V</span>: <span class="nb">Default</span> <span class="o">+</span><span class="w"> </span><span class="nb">Extend</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">W</span>: <span class="nb">Default</span> <span class="o">+</span><span class="w"> </span><span class="nb">Extend</span><span class="o">&lt;</span><span class="n">B</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">X</span>: <span class="nb">Default</span> <span class="o">+</span><span class="w"> </span><span class="nb">Extend</span><span class="o">&lt;</span><span class="n">C</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">from_iter</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">IntoIterator</span><span class="o">&lt;</span><span class="n">Item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">,</span><span class="w"> </span><span class="n">C</span><span class="p">)</span><span class="o">&gt;&gt;</span><span class="p">(</span><span class="n">iter</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">v</span>: <span class="nc">V</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Default</span>::<span class="n">default</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">w</span>: <span class="nc">W</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Default</span>::<span class="n">default</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">x</span>: <span class="nc">X</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Default</span>::<span class="n">default</span><span class="p">();</span><span class="w"></span>

<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">iter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">iter</span><span class="p">.</span><span class="n">into_iter</span><span class="p">();</span><span class="w"></span>

<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">reservation</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">iter</span><span class="p">.</span><span class="n">size_hint</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="p">(</span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">upper_bound</span><span class="p">))</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">upper_bound</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="p">(</span><span class="n">lower_bound</span><span class="p">,</span><span class="w"> </span><span class="nb">None</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">lower_bound</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">};</span><span class="w"></span>

<span class="w">        </span><span class="n">v</span><span class="p">.</span><span class="n">extend_reserve</span><span class="p">(</span><span class="n">reservation</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">w</span><span class="p">.</span><span class="n">extend_reserve</span><span class="p">(</span><span class="n">reservation</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">x</span><span class="p">.</span><span class="n">extend_reserve</span><span class="p">(</span><span class="n">reservation</span><span class="p">);</span><span class="w"></span>

<span class="w">        </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="n">c</span><span class="p">)</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">iter</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">v</span><span class="p">.</span><span class="n">extend</span><span class="p">(</span><span class="n">once</span><span class="p">(</span><span class="n">a</span><span class="p">));</span><span class="w"></span>
<span class="w">            </span><span class="n">w</span><span class="p">.</span><span class="n">extend</span><span class="p">(</span><span class="n">once</span><span class="p">(</span><span class="n">b</span><span class="p">));</span><span class="w"></span>
<span class="w">            </span><span class="n">x</span><span class="p">.</span><span class="n">extend</span><span class="p">(</span><span class="n">once</span><span class="p">(</span><span class="n">c</span><span class="p">));</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>

<span class="w">        </span><span class="n">Tuple</span><span class="p">(</span><span class="n">v</span><span class="p">,</span><span class="w"> </span><span class="n">w</span><span class="p">,</span><span class="w"> </span><span class="n">x</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vec</span><span class="o">!</span><span class="p">[(</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mf">2.0</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;3&quot;</span><span class="p">)];</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">Tuple</span><span class="p">(</span><span class="n">n</span><span class="p">,</span><span class="w"> </span><span class="n">f</span><span class="p">,</span><span class="w"> </span><span class="n">s</span><span class="p">)</span>: <span class="nc">Tuple</span><span class="o">&lt;</span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">_</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">_</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">_</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">b</span><span class="p">.</span><span class="n">into_iter</span><span class="p">().</span><span class="n">collect</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="210587948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210587948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210587948">(Sep 19 2020 at 00:18)</a>:</h4>
<p>Conceptually it seems reasonable.  I feel like there's some reluctance to add more macro-for-all-tuples-up-to-12 things, though.</p>
<p>It does make the think that the whole FromIterator vs Default+Extend thing is unfortunate.  (See also <code>Iterator::partition</code>.)</p>



<a name="210588166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588166">(Sep 19 2020 at 00:23)</a>:</h4>
<p>yea, that made me sad when I ran into it</p>



<a name="210588176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588176">(Sep 19 2020 at 00:23)</a>:</h4>
<p>really feels like <code>Default + Extend</code> is what <code>FromIterator</code> should be</p>



<a name="210588224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588224">(Sep 19 2020 at 00:24)</a>:</h4>
<p>I have some prior art for rayon, at least for tuple pairs:</p>
<ul>
<li><a href="https://github.com/rayon-rs/rayon/pull/604"><code>ParallelExtend for (A, B)</code></a></li>
<li>(draft) <a href="https://github.com/rayon-rs/rayon/pull/802"><code>FromParallelIterator for (A, B)</code></a></li>
</ul>



<a name="210588231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588231">(Sep 19 2020 at 00:24)</a>:</h4>
<p>oh cool!</p>



<a name="210588244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588244">(Sep 19 2020 at 00:25)</a>:</h4>
<p>this enables cool things like nested <code>unzip</code>, to any arbitrary level like <code>((A, B), (C, (D, E)))</code></p>



<a name="210588249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588249">(Sep 19 2020 at 00:25)</a>:</h4>
<p>yw</p>



<a name="210588250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588250">(Sep 19 2020 at 00:25)</a>:</h4>
<p>YEA</p>



<a name="210588251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588251">(Sep 19 2020 at 00:25)</a>:</h4>
<p>gdi</p>



<a name="210588252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588252">(Sep 19 2020 at 00:25)</a>:</h4>
<p>yea*</p>



<a name="210588294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588294">(Sep 19 2020 at 00:26)</a>:</h4>
<p>that was the first thing I saw in the pr and i was like oh shit!</p>



<a name="210588306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588306">(Sep 19 2020 at 00:26)</a>:</h4>
<p>and an unzipping <code>collect</code> for <code>Result&lt;(A, B), E&gt;</code> is pretty neat too, I think</p>



<a name="210588312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588312">(Sep 19 2020 at 00:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio/near/210587948">said</a>:</p>
<blockquote>
<p>Conceptually it seems reasonable.  I feel like there's some reluctance to add more macro-for-all-tuples-up-to-12 things, though.</p>
<p>It does make the think that the whole FromIterator vs Default+Extend thing is unfortunate.  (See also <code>Iterator::partition</code>.)</p>
</blockquote>
<p>I guess that menas we could work around the <code>up-to-12</code> things by only implementing it for (A, B) and making ppl nest the tuples :)</p>



<a name="210588313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588313">(Sep 19 2020 at 00:26)</a>:</h4>
<p>I was thinking that the other option here would be to call it <code>unzip</code> rather than <code>collect</code> -- which has the advantage that it could go in unstable</p>



<a name="210588319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588319">(Sep 19 2020 at 00:26)</a>:</h4>
<p>_not actually serious_</p>



<a name="210588336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588336">(Sep 19 2020 at 00:27)</a>:</h4>
<p>hmm</p>



<a name="210588338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588338">(Sep 19 2020 at 00:27)</a>:</h4>
<p>oh yea because you cant do unstable trait impls</p>



<a name="210588345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588345">(Sep 19 2020 at 00:27)</a>:</h4>
<p>so would you then just have <code>unzip</code> use <code>Default + Extend</code> as its bounds instead of <code>FromIterator</code>?</p>



<a name="210588390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588390">(Sep 19 2020 at 00:28)</a>:</h4>
<p>_wondering how this impl would prevent ppl from using it instead of collect when tuples aren't involved_</p>



<a name="210588395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588395">(Sep 19 2020 at 00:28)</a>:</h4>
<p>note, if it's not literally <code>FromIterator</code>, the <code>Result</code> case above won't work</p>



<a name="210588405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588405">(Sep 19 2020 at 00:28)</a>:</h4>
<p>oh</p>



<a name="210588416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588416">(Sep 19 2020 at 00:29)</a>:</h4>
<p>well thats fine, unzip could use FromIterator and those impls could use Default + Extend like my example</p>



<a name="210588491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588491">(Sep 19 2020 at 00:30)</a>:</h4>
<p>Basically, I was thinking that since it can't delegate to <code>FromIterator</code> on the inner collections, then just having a separate method that doesn't mention <code>FromIterator</code> at all might be fine.  But as cuviper notes, that does preclude using the other <code>FromIterator</code>s with it....</p>
<p>(Though personally I'm not a huge fan of that impl, since nobody can ever find it...)</p>



<a name="210588495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588495">(Sep 19 2020 at 00:31)</a>:</h4>
<p>IMO, adding an inherent <code>unzip</code> method to tuples is fine for unstable exploration, although it will be annoying to deal with lang items</p>



<a name="210588508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588508">(Sep 19 2020 at 00:31)</a>:</h4>
<p>but ultimately I think it would be nicer to actually have the real <code>Extend</code> and <code>FromIterator</code></p>



<a name="210588522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588522">(Sep 19 2020 at 00:31)</a>:</h4>
<p>I was thinking a method on <code>Iterator&lt;Item = (...)&gt;</code>, not an inherent on tuples.</p>



<a name="210588577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588577">(Sep 19 2020 at 00:32)</a>:</h4>
<p><code>Iterator::unzip</code> already exists</p>



<a name="210588636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588636">(Sep 19 2020 at 00:33)</a>:</h4>
<p>do you mean like <code>unzip3</code>, <code>unzip4</code>, etc?</p>



<a name="210588694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588694">(Sep 19 2020 at 00:34)</a>:</h4>
<p>the numbering wouldn't actually matter in practice right?</p>



<a name="210588703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588703">(Sep 19 2020 at 00:34)</a>:</h4>
<p>unless we artificially limited the item types on each fn</p>



<a name="210588713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588713">(Sep 19 2020 at 00:34)</a>:</h4>
<p>basically <code>unzip3</code> would have to be the <code>FromIterator</code> impl you'd do for a 3 tuple</p>



<a name="210588721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588721">(Sep 19 2020 at 00:34)</a>:</h4>
<p>and it just directly uses Extend and Default</p>



<a name="210588739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588739">(Sep 19 2020 at 00:35)</a>:</h4>
<p>don't like that idea</p>



<a name="210588811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588811">(Sep 19 2020 at 00:36)</a>:</h4>
<p>wait actually no i thikn i get it more</p>



<a name="210588820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588820">(Sep 19 2020 at 00:36)</a>:</h4>
<p>because if you did it ontop of FromIterator again youre right back at square one of it being instantly stable</p>



<a name="210588873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588873">(Sep 19 2020 at 00:37)</a>:</h4>
<p>the current <code>Iterator::unzip</code> just directly does a loop like your initial code here</p>



<a name="210588878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588878">(Sep 19 2020 at 00:37)</a>:</h4>
<p>although with a <code>fold</code> instead of a <code>for</code> loop</p>



<a name="210588882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588882">(Sep 19 2020 at 00:37)</a>:</h4>
<p>makes sense</p>



<a name="210588957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210588957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210588957">(Sep 19 2020 at 00:39)</a>:</h4>
<p>I don't really think a bunch of new <code>unzipN</code> methods is the way to go, but I'm not sure what <span class="user-mention" data-user-id="125270">@scottmcm</span> meant</p>



<a name="210589433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210589433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210589433">(Sep 19 2020 at 00:51)</a>:</h4>
<p>alternatively</p>



<a name="210589436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210589436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210589436">(Sep 19 2020 at 00:51)</a>:</h4>
<p>we could implement <code>Default</code> and <code>Extend</code> for tuples and then add this impl for FromIterator</p>



<a name="210589440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210589440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210589440">(Sep 19 2020 at 00:51)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">,</span><span class="w"> </span><span class="n">C</span><span class="p">,</span><span class="w"> </span><span class="n">V</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="o">&gt;</span><span class="w"> </span><span class="n">FromIterator</span><span class="o">&lt;</span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">,</span><span class="w"> </span><span class="n">C</span><span class="p">)</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Tuple</span><span class="o">&lt;</span><span class="n">V</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">V</span>: <span class="nb">Default</span> <span class="o">+</span><span class="w"> </span><span class="nb">Extend</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">W</span>: <span class="nb">Default</span> <span class="o">+</span><span class="w"> </span><span class="nb">Extend</span><span class="o">&lt;</span><span class="n">B</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">X</span>: <span class="nb">Default</span> <span class="o">+</span><span class="w"> </span><span class="nb">Extend</span><span class="o">&lt;</span><span class="n">C</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">from_iter</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">IntoIterator</span><span class="o">&lt;</span><span class="n">Item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">,</span><span class="w"> </span><span class="n">C</span><span class="p">)</span><span class="o">&gt;&gt;</span><span class="p">(</span><span class="n">iter</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">tuple</span>: <span class="nc">Tuple</span><span class="o">&lt;</span><span class="n">V</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Default</span>::<span class="n">default</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="n">tuple</span><span class="p">.</span><span class="n">extend</span><span class="p">(</span><span class="n">iter</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">tuple</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="210589485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210589485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210589485">(Sep 19 2020 at 00:52)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">struct</span> <span class="nc">Tuple</span><span class="o">&lt;</span><span class="n">V</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="o">&gt;</span><span class="p">(</span><span class="n">V</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="p">);</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">,</span><span class="w"> </span><span class="n">C</span><span class="p">,</span><span class="w"> </span><span class="n">V</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">Extend</span><span class="o">&lt;</span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">,</span><span class="w"> </span><span class="n">C</span><span class="p">)</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Tuple</span><span class="o">&lt;</span><span class="n">V</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">V</span>: <span class="nb">Extend</span><span class="o">&lt;</span><span class="n">A</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">W</span>: <span class="nb">Extend</span><span class="o">&lt;</span><span class="n">B</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">X</span>: <span class="nb">Extend</span><span class="o">&lt;</span><span class="n">C</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">extend</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">IntoIterator</span><span class="o">&lt;</span><span class="n">Item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="p">,</span><span class="w"> </span><span class="n">C</span><span class="p">)</span><span class="o">&gt;&gt;</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">iter</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">iter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">iter</span><span class="p">.</span><span class="n">into_iter</span><span class="p">();</span><span class="w"></span>

<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">reservation</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">iter</span><span class="p">.</span><span class="n">size_hint</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="p">(</span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">upper_bound</span><span class="p">))</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">upper_bound</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="p">(</span><span class="n">lower_bound</span><span class="p">,</span><span class="w"> </span><span class="nb">None</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">lower_bound</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">};</span><span class="w"></span>

<span class="w">        </span><span class="bp">self</span><span class="p">.</span><span class="mf">0.</span><span class="n">extend_reserve</span><span class="p">(</span><span class="n">reservation</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="p">.</span><span class="mf">1.</span><span class="n">extend_reserve</span><span class="p">(</span><span class="n">reservation</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="p">.</span><span class="mf">2.</span><span class="n">extend_reserve</span><span class="p">(</span><span class="n">reservation</span><span class="p">);</span><span class="w"></span>

<span class="w">        </span><span class="n">iter</span><span class="p">.</span><span class="n">into_iter</span><span class="p">().</span><span class="n">fold</span><span class="p">((),</span><span class="w"> </span><span class="o">|</span><span class="p">(),</span><span class="w"> </span><span class="n">values</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="bp">self</span><span class="p">.</span><span class="mf">0.</span><span class="n">extend</span><span class="p">(</span><span class="n">once</span><span class="p">(</span><span class="n">values</span><span class="p">.</span><span class="mi">0</span><span class="p">));</span><span class="w"></span>
<span class="w">            </span><span class="bp">self</span><span class="p">.</span><span class="mf">1.</span><span class="n">extend</span><span class="p">(</span><span class="n">once</span><span class="p">(</span><span class="n">values</span><span class="p">.</span><span class="mi">1</span><span class="p">));</span><span class="w"></span>
<span class="w">            </span><span class="bp">self</span><span class="p">.</span><span class="mf">2.</span><span class="n">extend</span><span class="p">(</span><span class="n">once</span><span class="p">(</span><span class="n">values</span><span class="p">.</span><span class="mi">2</span><span class="p">));</span><span class="w"></span>
<span class="w">        </span><span class="p">});</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">V</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="o">&gt;</span><span class="w"> </span><span class="nb">Default</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Tuple</span><span class="o">&lt;</span><span class="n">V</span><span class="p">,</span><span class="w"> </span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">V</span>: <span class="nb">Default</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">W</span>: <span class="nb">Default</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">X</span>: <span class="nb">Default</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">default</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">Tuple</span><span class="p">(</span><span class="nb">Default</span>::<span class="n">default</span><span class="p">(),</span><span class="w"> </span><span class="nb">Default</span>::<span class="n">default</span><span class="p">(),</span><span class="w"> </span><span class="nb">Default</span>::<span class="n">default</span><span class="p">())</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="210589497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210589497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210589497">(Sep 19 2020 at 00:52)</a>:</h4>
<p>this is even further from the "allow experimentation via unstable" goal, lol</p>



<a name="210634310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210634310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210634310">(Sep 19 2020 at 20:41)</a>:</h4>
<p>Oh, right 12 new <code>unzipN</code> methods sounds terrible.  Apparently I should have thought that one through further :P</p>



<a name="210634393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210634393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210634393">(Sep 19 2020 at 20:43)</a>:</h4>
<p>lol</p>



<a name="210634688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210634688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210634688">(Sep 19 2020 at 20:50)</a>:</h4>
<p>so does that mean we're back at thinking this would have to be done via an instantly stable FromIterator impl?</p>



<a name="210634694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210634694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210634694">(Sep 19 2020 at 20:50)</a>:</h4>
<p>and if so, do we think this change would need an RFC? is it likely to be accepted? is it worth pursueing?</p>



<a name="210635109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210635109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210635109">(Sep 19 2020 at 21:01)</a>:</h4>
<p>It would get the <code>needs-fcp</code> label, but that doesn't necessarily mean an RFC -- I just got <a href="https://github.com/rust-lang/rust/issues/76310">#76310</a> in without one, though that was following well-established patterns.</p>



<a name="210635138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210635138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210635138">(Sep 19 2020 at 21:02)</a>:</h4>
<p>Hmm, coming at this from the other direction, if tuples are <code>FromIterator</code>, they should probably be <code>(Into)Iterator</code> too.</p>



<a name="210635208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210635208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210635208">(Sep 19 2020 at 21:03)</a>:</h4>
<p>So maybe this starts to hit RFC territory?</p>
<p>Presumably there's a reason that we can't <code>for (i, j) in (vec1, vec2)</code> today, and have to go through named methods?</p>



<a name="210635279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210635279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210635279">(Sep 19 2020 at 21:04)</a>:</h4>
<p>Oh, no, that's probably because the "what if the lengths don't match?" behaviour question.  Which is a problem that <code>FromIterator</code> doesn't have...</p>



<a name="210635281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210635281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210635281">(Sep 19 2020 at 21:04)</a>:</h4>
<p><span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="210636218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210636218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210636218">(Sep 19 2020 at 21:28)</a>:</h4>
<p>For different lengths, same answer as zip... and I did this in rayon too! <span aria-label="big smile" class="emoji emoji-1f604" role="img" title="big smile">:big_smile:</span><br>
<a href="https://github.com/rayon-rs/rayon/pull/711">https://github.com/rayon-rs/rayon/pull/711</a></p>



<a name="210636242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210636242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210636242">(Sep 19 2020 at 21:29)</a>:</h4>
<p>For all these, I think the motivation was stronger in rayon because it's harder to do the parallel thing manually</p>



<a name="210636304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210636304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210636304">(Sep 19 2020 at 21:30)</a>:</h4>
<p>But, it would still be neat to see the same in <code>std</code></p>



<a name="210648628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210648628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210648628">(Sep 20 2020 at 04:20)</a>:</h4>
<p>it's really nice to have rayon as prior art here</p>



<a name="210775012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/210775012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matt Brubeck <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#210775012">(Sep 21 2020 at 17:40)</a>:</h4>
<p>For what it's worth, I recently reinvented <code>unzip</code> because I forgot it existed and didn't find it when searching in <code>std</code> and <code>itertools</code> docs.  The first thing I looked for was <code>impl FromIterator for (T, U)</code>.  So this proposal would definitely have helped me:<br>
<a href="https://users.rust-lang.org/t/how-to-use-iterators-that-lead-to-two-collects/48985">https://users.rust-lang.org/t/how-to-use-iterators-that-lead-to-two-collects/48985</a></p>



<a name="213970044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/213970044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#213970044">(Oct 20 2020 at 19:43)</a>:</h4>
<p><span class="user-mention" data-user-id="220273">@Jane Lusby</span> were you planning to try a PR for this? I think <code>IntoIterator</code>, <code>FromIterator</code>, and <code>Extend</code>are all viable for tuple pairs at least, acting as simple <code>zip</code> and <code>unzip</code>.</p>



<a name="213970063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/213970063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#213970063">(Oct 20 2020 at 19:43)</a>:</h4>
<p>if not, I'm willing to try for it myself</p>



<a name="213972814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/213972814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#213972814">(Oct 20 2020 at 20:07)</a>:</h4>
<p><span class="user-mention" data-user-id="138448">@cuviper</span> if you're interested in doing pls do</p>



<a name="213972836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/213972836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#213972836">(Oct 20 2020 at 20:07)</a>:</h4>
<p>I probably wouldn't get around to it for a while otherwise</p>



<a name="214028318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/214028318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#214028318">(Oct 21 2020 at 09:39)</a>:</h4>
<p>Will this account for possibly in the future extending the impl to N-length tuples? I asked <span class="user-mention" data-user-id="124288">@oli</span> whether this would be possible I think a year ago, and I believe the answer was that _in theory_ it may be possible someday.</p>
<p>I think it'd be nice if this addition at least kept the option open to enable support for any-length tuples some day. I assume it does, but figured it's still worth a mention.</p>



<a name="214067320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/214067320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#214067320">(Oct 21 2020 at 15:28)</a>:</h4>
<p>You certainly can add separate impls for 3, 4, ...</p>



<a name="214067561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/214067561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#214067561">(Oct 21 2020 at 15:30)</a>:</h4>
<p>For truly <em>any</em> length, we would need variadic types in some form, but I don't see any reason why adding pairs now would block that later.</p>



<a name="214078514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/214078514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshua Wuyts <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#214078514">(Oct 21 2020 at 16:41)</a>:</h4>
<p>Cool! That's what I was hoping the answer would be</p>



<a name="214079137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/214079137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#214079137">(Oct 21 2020 at 16:45)</a>:</h4>
<p>this reminds me I need to work on getting SIMD-vectors-as-arrays...</p>



<a name="214079765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/214079765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#214079765">(Oct 21 2020 at 16:50)</a>:</h4>
<p><span class="user-mention" data-user-id="220273">@Jane Lusby</span> If they're all of the same type, wouldn't the final step make more sense w/</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">arr</span>: <span class="p">[</span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">_</span><span class="o">&gt;</span><span class="p">;</span><span class="w"> </span><span class="n">_</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">b</span><span class="p">.</span><span class="n">into_iter</span><span class="p">().</span><span class="n">collect</span><span class="p">();</span><span class="w"></span>
</code></pre></div>

<p>Or is this specifically for cases where you know they aren't the same type</p>



<a name="214080304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/214080304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#214080304">(Oct 21 2020 at 16:53)</a>:</h4>
<p>I think I'd prefer consistency of tuple-of-items to tuple-of-collections, and array to array</p>



<a name="214080315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/214080315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#214080315">(Oct 21 2020 at 16:53)</a>:</h4>
<p>I don't remember the exact context of this originally but I think we'd want support for when the types are different</p>



<a name="214080357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/214080357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#214080357">(Oct 21 2020 at 16:54)</a>:</h4>
<p>arrays may also be confusing if we get <code>FromIterator&lt;T&gt; for [T; N]</code> vs. <code>FromIterator&lt;[T; N]&gt; for [C; N] where C: FromIterator&lt;T&gt;</code></p>



<a name="214080459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/214080459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#214080459">(Oct 21 2020 at 16:54)</a>:</h4>
<p>yeaaaah</p>



<a name="214112856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/impl%20FromIterator%20for%20tuples%20of%20items%20to%20tuples%20of%20collectio/near/214112856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/impl.20FromIterator.20for.20tuples.20of.20items.20to.20tuples.20of.20collectio.html#214112856">(Oct 21 2020 at 20:49)</a>:</h4>
<p>I did the <code>IntoIterator</code> bit first: <a href="https://github.com/rust-lang/rust/pull/78204">https://github.com/rust-lang/rust/pull/78204</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>